package com.wanmait.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 房间表
 */
@Data
@Accessors(chain = true)
@TableName(value = "room")
public class Room {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 楼栋id
     */
    @TableField(value = "building_id")
    @NotNull(message = "楼栋不能为空")
    private Integer buildingId;
    @TableField(exist = false)
    private Building building;
    /**
     * 单元id
     */
    @TableField(value = "unit_id")
    @NotNull(message = "单元不能为空")
    private Integer unitId;
    @TableField(exist = false)
    private Unit unit;
    /**
     * 层数
     */
    @TableField(value = "`floor`")
    @NotNull(message = "楼层不能为空")
    private Integer floor;

    /**
     * 房间名
     */
    @TableField(value = "room_name")
    @NotEmpty(message = "房间名不能为空")
    @Pattern(regexp = "^\\d+$",message = "房间名只能是数字的结合")
    private String roomName;

    /**
     * 业主id
     */
    @TableField(value = "owner_id")
    private Integer ownerId;
    @TableField(exist = false)
    private User owner;
    /**
     * 建筑面积
     */
    @TableField(value = "gross_area")
    @NotNull(message = "建筑面积不能为空")
    @Digits(integer = 10, fraction = 2, message = "建筑面积必须保留小数点后两位")
    private Double grossArea;

    /**
     * 室内面积
     */
    @TableField(value = "usable_area")
    @NotNull(message = "室内面积不能为空")
    @Digits(integer = 10, fraction = 2, message = "室内面积必须保留小数点后两位")
//    @ValidUsableArea()
    private Double usableArea;

    /**
     * 物业费单价
     */
    @TableField(value = "price")
    @NotNull(message = "物业费单价不能为空")
    private BigDecimal price;

    /**
     * 是否自住
     */
    @TableField(value = "live")
    private String live;

    /**
     * 是否出售
     */
    @TableField(value = "sold")
    private String sold;

    /**
     * 是否出租
     */
    @TableField(value = "lease")
    private String lease;

    /**
     * 是否转租
     */
    @TableField(value = "re_lease")
    private String reLease;

    /**
     * 状态(宿舍、商铺、自住)
     */
    @TableField(value = "`type`")
    @NotEmpty(message = "需要对该房屋有一个说明是用来做什么的")
    private String type;

    /**
     * 几室几厅，明厅
     */
    @TableField(value = "message")
    @NotEmpty(message = "需要对该房屋的户型有一个说明")
    private String message;

    /**
     * 欠费时间（月份）
     */
    @TableField(value = "owe_time")
    private Integer oweTime;

    /**
     * 缴费到几月份
     */
    @TableField(value = "fee_time")
    private Date feeTime;

    /**
     * 创建用户id
     */
    @TableField(value = "creat_by")
    private Integer creatBy;

    /**
     * 创建时间
     */
    @TableField(value = "creat_time")
    private Date creatTime;

    /**
     * 更新用户id
     */
    @TableField(value = "update_by")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 逻辑删除
     */
    @TableField(value = "`enable`")
    private Boolean enable;
}